/**
 * 
 */
package me.dbest.javase.learn.bitManipultaion;


/**
 * @author nishant.awasthi
 *
 */
public class MQTTBitRepn {

	/**
	 * 
	 */
	public MQTTBitRepn() {
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int X=321;
		int digit=0;
		//System.out.println(Integer.toBinaryString(0x80));
		//System.out.println(Integer.toBinaryString(0xFF));
		do {
			digit = X % 128;
			X = X / 128;
			
			//System.out.print("prev digit " + Integer.toBinaryString(digit) +"\t");
			 // if there are more digits to encode, set the top bit of this digit
			  if ( X > 0 ){
			    digit = (digit | 0x80);
			  }
			  System.out.print(digit+"\t");
			  System.out.print(Integer.toHexString(digit));
			  System.out.print("\t"+ X +"\n");
			  
			
		} while (X> 0);

	}

}
